package com.blog.study.study8;

import redis.clients.jedis.Jedis;

import java.util.HashMap;
import java.util.Map;

/**
 * 〈Redis 的数据类型〉<br>
 *
 * @author 未绪
 * @time 2017/12/12 19:33
 */
public class JedisDataClassDemo {

    public static final String HOST="192.168.88.129";
    public static final int PORT=6380;

    public static void main(String[] args) {
        Jedis jedis=new Jedis(HOST,PORT);

        //测试Hash
        jedis.hset("userInfo","userName","张俊强");
        jedis.hset("userInfo","userAge","15");
        jedis.hset("userInfo","userSex","男");
        System.out.println(jedis.hget("userInfo", "userName"));
        //测试Set

        jedis.sadd("employeeInfo","张三","李四","王五");
        jedis.smembers("employeeInfo").forEach((String str)->System.out.println(str));
        //测试List
        jedis.lpush("studentSex","男","女","中性");
        while (jedis.llen("studentSex")!=0){
            System.out.println(jedis.lpop("studentSex"));
        }

        //测试ZSet

        Map<String,Double> map=new HashMap();
        map.put("tom",10.0);
        map.put("lily",20.0);
        map.put("tina",40.0);

        jedis.zadd("teacherInfo",map);

        jedis.zrange("teacherInfo",0,-1).forEach((String str)->{
            System.out.println(str);
        });

    }

}
